<html>
<head><meta charset="utf-8"><title>-Zinstrument-coverage with --crate-type = staticlib? · t-compiler · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/index.html">t-compiler</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html">-Zinstrument-coverage with --crate-type = staticlib?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="239181406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239181406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239181406">(May 18 2021 at 00:48)</a>:</h4>
<p>Hey, folks. Where's the best place to ask questions about -Zinstrument-coverage?</p>
<p>I'm trying to run code coverage for a Windows DLL, which contains a mixture of Rust code and C++ code. The Rust code is compiled using <code>--crate-type staticlib</code>, and the C++ code references symbols exported by the Rust code using <code>#[no_mangle]</code> and similar.  All of this works fine (when not compiling with -Zinstrument-coverage).</p>
<p>When compiling with <code>RUSTFLAGS=-Zinstrument-coverage</code>, though, the DLL fails to link, because it cannot resolve the symbol <code>__llvm_profile_runtime</code>. It looks like this symbol is defined in <code>libprofiler_runtime-XXXXX.rlib</code>, which seems reasonable. However, that symbol is _not_ carried over to the static lib generated by Rustc / Cargo, so it fails to be resolved at link time.  I'm guessing that this symbol is defined by C/C++ code, which is why it isn't being implicitly carried over to the static lib generated by Rust.</p>
<p>Is there a reasonable solution to this?  I sorta understand why it's happening, but I don't see any obvious great solution.</p>



<a name="239229003"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239229003" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> lqd <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239229003">(May 18 2021 at 10:14)</a>:</h4>
<p>This seems a good place to ask such questions :) but I believe it'll be best to mention <span class="user-mention" data-user-id="296355">@Rich Kadel</span> or <span class="user-mention" data-user-id="116883">@tmandry</span>, as the primary author and reviewer of that work, they'll be the most able to answer them</p>



<a name="239344704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239344704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239344704">(May 19 2021 at 00:05)</a>:</h4>
<p><span class="user-mention" data-user-id="274471">@Arlie Davis</span> can you throw <code>libprofiler_runtime-XXXXX.rlib</code> on the linker line and see what happens?</p>



<a name="239344804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239344804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239344804">(May 19 2021 at 00:06)</a>:</h4>
<p>(<code>rlib</code>s are just static lib archives with extra files, I think some linkers at least let you add them directly)</p>



<a name="239344960"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239344960" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239344960">(May 19 2021 at 00:08)</a>:</h4>
<p>I think I tried that, and I think it works. But it's not much of a solution, because it requires knowing the path to the libstd install, as well as the -XXX hash part of the filename.</p>



<a name="239345027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345027">(May 19 2021 at 00:09)</a>:</h4>
<p>yeah. of course normally rustc would do this for you, but since you're building a staticlib it doesn't control linking anymore</p>



<a name="239345059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345059">(May 19 2021 at 00:09)</a>:</h4>
<p>Right.  For Rust code, that's fine because rustc pulls in all of the dependent (Rust) code into the static lib file. But it apparently doesn't do the same for non-Rust code that is packaged in upstream .rlib files.</p>



<a name="239345203"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345203" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345203">(May 19 2021 at 00:11)</a>:</h4>
<p>yeah, and I'm unclear on whether rustc actually considers this to be a dependency</p>



<a name="239345227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345227">(May 19 2021 at 00:11)</a>:</h4>
<p>so generally the lib will be in <code>$(rustc --print=sysroot)/lib/rustlib/$TARGET_TRIPLE/lib</code></p>



<a name="239345323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345323">(May 19 2021 at 00:12)</a>:</h4>
<p>the <code>--print=sysroot</code> thing you can rely on always being there. the exact path I'm not sure about</p>



<a name="239345394"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345394" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345394">(May 19 2021 at 00:13)</a>:</h4>
<p>it's not clear to me that bundling the profiler runtime into a staticlib binary would be <em>correct</em>, since you might end up with duplicate symbols if you try linking multiple instrumented staticlibs</p>



<a name="239345448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345448">(May 19 2021 at 00:14)</a>:</h4>
<p>I think you're already in trouble if you try to link multiple staticlibs, because they already contain duplicated copies of libstd and friends.</p>



<a name="239345461"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345461" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345461">(May 19 2021 at 00:14)</a>:</h4>
<p>Basically, you get one Rust staticlib per link invocation.</p>



<a name="239345490"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345490" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345490">(May 19 2021 at 00:14)</a>:</h4>
<p>oh really..</p>



<a name="239345538"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345538" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345538">(May 19 2021 at 00:15)</a>:</h4>
<p>(you can work around issues like this with weak symbols, but you have to <em>know</em> that every definition is the same)</p>



<a name="239345604"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345604" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345604">(May 19 2021 at 00:16)</a>:</h4>
<p>Yeah, that's not really a path I want to go down. My team has already accepted the constraint of "1 Rust staticlib per module".  Also, weak symbols are a platform-specific concept; Win32 / PE has no such concept, so it just fails.</p>



<a name="239345679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345679">(May 19 2021 at 00:17)</a>:</h4>
<p>so, clang solves this with an option that can print the path to any library it ships with</p>



<a name="239345722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345722">(May 19 2021 at 00:18)</a>:</h4>
<p>Verified, manually linking against libprofiler_builtins works.</p>



<a name="239345797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345797">(May 19 2021 at 00:19)</a>:</h4>
<p>so you can say e.g. <code>clang --target=foo -print-file-name=libunwind.so</code> and it will give you the path for that target</p>



<a name="239345849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345849">(May 19 2021 at 00:20)</a>:</h4>
<p>I think the best way to solve this would be with a flag like that</p>



<a name="239345936"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345936" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345936">(May 19 2021 at 00:21)</a>:</h4>
<p>bundling into the staticlib might work, but it could become a problem for anyone doing cross-language instrumentation</p>



<a name="239345937"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345937" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345937">(May 19 2021 at 00:21)</a>:</h4>
<p>That seems reasonable. Do you know whether <code>__llvm_profile_runtime</code> is implemented in C/C++ or Rust?  I could just link directly against the appropriate LLVM library.</p>



<a name="239345947"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345947" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345947">(May 19 2021 at 00:21)</a>:</h4>
<p>ah so I think it is implemented in C/C++</p>



<a name="239345962"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239345962" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239345962">(May 19 2021 at 00:22)</a>:</h4>
<p>but you're allowed to override it, according to <a href="https://clang.llvm.org/docs/SourceBasedCodeCoverage.html#id10">these docs</a></p>



<a name="239346020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346020">(May 19 2021 at 00:22)</a>:</h4>
<p>That's what I was guessing.  It might be sufficient to provide a copy of the LLVM static lib, outside of <code>libprofiler_runtime-XXX.rlib</code>, for situations like this.</p>



<a name="239346052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346052">(May 19 2021 at 00:23)</a>:</h4>
<p>yeah, I'm trying to remember if the rlib is just a repackaging of that</p>



<a name="239346055"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346055" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346055">(May 19 2021 at 00:23)</a>:</h4>
<p>If the path I need to build is just <code>$TOOLCHAIN/$TRIPLE/libllvm_profile_runtime.lib</code> or some such, then that would work for me.</p>



<a name="239346084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346084">(May 19 2021 at 00:23)</a>:</h4>
<p>I'm guessing that whatever part of <code>libprofiler_runtime</code> is in Rust, is already being packaged into the static lib, and it's only the C/C++ part that isn't.</p>



<a name="239346183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346183">(May 19 2021 at 00:25)</a>:</h4>
<p>yeah <a href="https://github.com/rust-lang/rust/blob/master/library/profiler_builtins/build.rs">it is</a></p>



<a name="239346232"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346232" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346232">(May 19 2021 at 00:25)</a>:</h4>
<p>there is actually no Rust code in that library at all</p>



<a name="239346336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346336">(May 19 2021 at 00:26)</a>:</h4>
<p>Neat.</p>



<a name="239346375"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346375" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346375">(May 19 2021 at 00:27)</a>:</h4>
<p>I'm not sure if LLVM doesn't export a lib target for this, or if Rust is intentionally building a subset to save space, or what</p>



<a name="239346534"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346534" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346534">(May 19 2021 at 00:29)</a>:</h4>
<div class="codehilite"><pre><span></span><code>link /dump /symbols c:\llvm\lib\clang\11.0.0\lib\windows\clang_rt.profile-x86_64.lib | findstr llvm_profile_runtime
</code></pre></div>
<p>Looks like it's here.</p>



<a name="239346603"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239346603" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239346603">(May 19 2021 at 00:30)</a>:</h4>
<p>I guess I could link to that.  I feel a bit queasy about using version $FOO of rustc, and version $BAR of LLVM, though.</p>



<a name="239347845"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/131828-t-compiler/topic/-Zinstrument-coverage%20with%20--crate-type%20%3D%20staticlib%3F/near/239347845" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Arlie Davis <a href="https://rust-lang.github.io/zulip_archive/stream/131828-t-compiler/topic/-Zinstrument-coverage.20with.20--crate-type.20.3D.20staticlib.3F.html#239347845">(May 19 2021 at 00:47)</a>:</h4>
<p>There's another problem, though. If you compile a Rust library with <code>--crate-type cdylib -Z instrument-coverage</code>, and run something that uses that DLL, it does generate a coverage file. However, when I run llvm-cov and point it at the DLL, it says that it can't find any coverage data in it.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>